package com.zklh.leetcode.top100.problem94;

import com.zklh.leetcode.tree.model.TreeNode;

import java.util.LinkedList;
import java.util.List;

public class Solution1 {

    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> trace = new LinkedList<>();
        traversal(root, trace);
        return trace;
    }

    public void traversal(TreeNode root, List<Integer> trace) {
        if (root != null) {
            traversal(root.left, trace);
            trace.add(root.val);
            traversal(root.right, trace);
        }
    }

    public static void main(String[] args) {
        TreeNode root = new TreeNode(1);
        root.right = new TreeNode(2);
        root.right.left = new TreeNode(3);

        Solution1 solution = new Solution1();
        List<Integer> trace = solution.inorderTraversal(root);
        System.out.println(trace);
    }
}
